﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _01.School
{
    public class Discipline : IComment
    {
        private string name;
        private uint numberOfLectures;
        private uint numberOfExircises;

        //TODO upgrade comment
        public Discipline(string name, uint numberOfLectures, uint numberOfExercises, string comment = null)
        {
            this.name = name;
            this.numberOfLectures = numberOfLectures;
            this.numberOfExircises = numberOfExircises;
            if (comment != null)
            {
                this.CommentList.Add(comment);
            }
        }
       
        public uint NumberOfExircises
        {
            get
            {
                return this.numberOfExircises;
            }
            set
            {
                if (value < 0)
                {
                    throw new ArgumentOutOfRangeException("The value of the exercises cannot be negative");
                }

                this.numberOfExircises = value;
            }
        }

        public string Name
        {
            get
            {
                return this.name;
            }
            private set
            {
                if (value.Trim().Length < 2 || string.IsNullOrEmpty(value))
                {
                    throw new ArgumentOutOfRangeException("The name cannot be shorter then 2 letters or null");
                }

                this.name = value;
            }
        }

        public uint NumberOfLectures
        {
            get
            {
                return this.numberOfLectures;
            }
            set
            {
                this.numberOfLectures = value;
            }
        }

        public List<string> CommentList
        {
            get 
            {
                return CommentList;
            }
            set 
            {
                this.CommentList = value;
            }
        }

        public void AddComment(string text)
        {
            CommentList.Add(text);
        }

        public override string ToString()
        {
            return string.Format("name: {0}, numberOfLectures: {1}, numberOfExircises: {2}", name, numberOfLectures, numberOfExircises);
        }
    }
}